﻿@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_LayoutCI.cshtml";
}

<form id="KSFormServer" class="KSFormLittle">
    <div>
        <div>
            <input type="text" style="display:none" name="cChr_Classification" value ="服务器">
            <input type="text" style="display:none" name="cChr_RelatedTicketID" value ="@ViewBag.TicketID">
            <div >
                <label >物理位置 : </label>
                <input type="text" name="cChr_Location" id="Server_CChr_Location" >
            </div>
            <div>
                <label>服务器名称 : </label>
@*                <select id="serverCI"></select>*@
                <input type="text" name="cChr_DeviceName" id="Server_CChr_DeviceName" class="required" >
            </div>
            <div >
                <label >类型 : </label>
                <input type="text" name="cChr_Type" id="Server_CChr_Type" >
            </div>
            <div >
                <label >管理IP : </label>
                <input type="text" name="cChr_IP" id="Server_CChr_IP" class="ip">
            </div>
        </div>
    </div>
        <div style="float:right;margin-right:25px">
        <input id="FormSavelittle" type="submit" title="添加" value="" style="background:url(../../Content/images/icon-status.png) 0  205px; width:28px; height:25px; border:0;outline:none;cursor:pointer" />
    </div>
</form>


@section scripts {
    <script type="text/javascript">               
        var makeInfo = [];
        $(document).ready(function () {
            //$(".custom-combobox").children().last().hide();
            SearchDataAll();

        })
        function SearchDataAll() {
            var tabName = "服务器";
            $.post("/CI/GetObjectTemplateAllList", { TabName: tabName}, function (response) {
                var bdData = response.rows;
                for (i = 0; i < bdData.length; i++) {
                    makeInfo.push(bdData[i].cChr_DeviceName);
                }
                $("#Server_CChr_DeviceName").autocomplete({
                    source: makeInfo,
                    select: function (event, ui) {
                        $.post("/CI/GetObjectTemplateInfo", { deviceName: ui.item.value }, function (response) {
                            var bdData = response.rows;
                            $("#Server_CChr_Location").val(bdData[0].cChr_Location);
                            $("#Server_CChr_Type").val(bdData[0].cChr_Type);
                            $("#Server_CChr_IP").val(bdData[0].cChr_IP);
                            $("#Server_CChr_DeviceName").val(bdData[0].cChr_DeviceName);
                        })
                    }
                });
            });
        }

        //AddCombobox($("#serverCI"), function (event, ui) {
        //    //textval=$('#serverCI option:selected').val();
        //    textval = $("#serverCI").find("option:selected").text();
            //$.post("/CI/GetObjectTemplateInfo", { deviceName: textval }, function (response) {
            //    var bdData = response.rows;
            //    $("#Server_CChr_Location").val(bdData[0].cChr_Location);
            //    $("#Server_CChr_Type").val(bdData[0].cChr_Type);
            //    $("#Server_CChr_IP").val(bdData[0].cChr_IP);
            //    $("#Server_CChr_DeviceName").val(bdData[0].cChr_DeviceName);
            //})
        //});
        function myfunctionTest() {
            //makeInfo = "[";
            //if (null != bdData && bdData.length > 0) {
            //    for (var i = 0; i < bdData.length; i++) {                      
            //        if (i < bdData.length - 1) {
            //            makeInfo +="\""+bdData[i].cChr_DeviceName +"\""+ ","
            //        }
            //        if (i > bdData.length - 1) {
            //            makeInfo += bdData[i].cChr_DeviceName 
            //        }
            //    }
            //}
            //if (makeInfo != "[") {
            //    makeInfo = makeInfo.substring(0, makeInfo.length - 1);
            //}
            //makeInfo += "]";
            //$("#serverCI").autocomplete("option", "source", makeInfo);
        }
    </script>
}